<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_Service_WindowsAzure_Storage_Queue - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.service.windowsazure.storage.queue.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.service.windowsazure.storage.queue.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.service.windowsazure.storage.queue" class="section"><div class="info"><h1 class="title">Zend_Service_WindowsAzure_Storage_Queue</h1></div>
    

    <p class="para">
        The Queue service stores messages that may be read by any client who has access to the
        storage account.
    </p>

    <p class="para">
        A queue can contain an unlimited number of messages, each of which can be up to 8 KB in
        size. Messages are generally added to the end of the queue and retrieved from the front of
        the queue, although first in/first out (<acronym class="acronym">FIFO</acronym>) behavior is not guaranteed.
        If you need to store messages larger than 8 KB, you can store message data as a queue or in
        a table and then store a reference to the data as a message in a queue.
    </p>

    <p class="para">
        Queue Storage is offered by Windows Azure as a <acronym class="acronym">REST</acronym>
        <acronym class="acronym">API</acronym> which is wrapped by the
        <span class="classname">Zend_Service_WindowsAzure_Storage_Queue</span> class in order to
        provide a native <acronym class="acronym">PHP</acronym> interface to the storage account.
    </p>

    <div class="section" id="zend.service.windowsazure.storage.queue.api"><div class="info"><h1 class="title">API Examples</h1></div>
        

        <p class="para">
            This topic lists some examples of using the
            <span class="classname">Zend_Service_WindowsAzure_Storage_Queue</span> class.  Other features
            are available in the download package, as well as a detailed <acronym class="acronym">API</acronym>
            documentation of those features.
        </p>

        <div class="section" id="zend.service.windowsazure.storage.queue.api.create-queue"><div class="info"><h1 class="title">Creating a queue</h1></div>
            

            <p class="para">
                Using the following code, a queue can be created on development storage.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.create-queue.example"><div class="info"><p><b>Example #1 Creating a queue</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();
$result = $storageClient-&gt;createQueue(&#039;testqueue&#039;);

echo &#039;Queue name is: &#039; . $result-&gt;Name;
</pre>

            </div>
        </div>

        <div class="section" id="zend.service.windowsazure.storage.queue.api.delete-queue"><div class="info"><h1 class="title">Deleting a queue</h1></div>
            

            <p class="para">
                Using the following code, a queue can be removed from development storage.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.delete-queue.example"><div class="info"><p><b>Example #2 Deleting a queue</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();
$storageClient-&gt;deleteQueue(&#039;testqueue&#039;);
</pre>

            </div>
        </div>

        <div class="section" id="zend.service.windowsazure.storage.queue.api.storing-queue"><div class="info"><h1 class="title">Adding a message to a queue</h1></div>
            

            <p class="para">
                Using the following code, a message can be added to a queue on development storage.
                Note that the queue has already been created before.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.storing-queue.example"><div class="info"><p><b>Example #3 Adding a message to a queue</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

// 3600 = time-to-live of the message, if omitted defaults to 7 days
$storageClient-&gt;putMessage(&#039;testqueue&#039;, &#039;This is a test message&#039;, 3600);
</pre>

            </div>
        </div>

        <div class="section" id="zend.service.windowsazure.storage.queue.api.read-queue"><div class="info"><h1 class="title">Reading a message from a queue</h1></div>
            

            <p class="para">
                Using the following code, a message can be read from a queue on development storage.
                Note that the queue and message have already been created before.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.read-queue.example"><div class="info"><p><b>Example #4 Reading a message from a queue</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

// retrieve 10 messages at once
$messages = $storageClient-&gt;getMessages(&#039;testqueue&#039;, 10);

foreach ($messages as $message) {
    echo $message-&gt;MessageText . &quot;\r\n&quot;;
}
</pre>

            </div>

            <p class="para">
                The messages that are read using  <span class="methodname">getMessages()</span> will be
                invisible in the queue for 30 seconds, after which the messages will re-appear in
                the queue. To mark a message as processed and remove it from the queue, use the
                 <span class="methodname">deleteMessage()</span> method.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.read-queue.processexample"><div class="info"><p><b>Example #5 Marking a message as processed</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

// retrieve 10 messages at once
$messages = $storageClient-&gt;getMessages(&#039;testqueue&#039;, 10);

foreach ($messages as $message) {
    echo $message . &quot;\r\n&quot;;

    // Mark the message as processed
    $storageClient-&gt;deleteMessage(&#039;testqueue&#039;, $message);
}
</pre>

            </div>
        </div>

        <div class="section" id="zend.service.windowsazure.storage.queue.api.peek-queue"><div class="info"><h1 class="title">Check if there are messages in a queue</h1></div>
            

            <p class="para">
                Using the following code, a queue can be checked for new messages. Note that the
                queue and message have already been created before.
            </p>

            <div class="example" id="zend.service.windowsazure.storage.queue.api.peek-queue.example"><div class="info"><p><b>Example #6 Check if there are messages in a queue</b></p></div>
                

                <pre class="programlisting brush: php">
$storageClient = new Zend_Service_WindowsAzure_Storage_Queue();

// retrieve 10 messages at once
$messages = $storageClient-&gt;peekMessages(&#039;testqueue&#039;, 10);

foreach ($messages as $message) {
    echo $message-&gt;MessageText . &quot;\r\n&quot;;
}
</pre>

            </div>

            <p class="para">
                Note that messages that are read using  <span class="methodname">peekMessages()</span> will
                not become invisible in the queue, nor can they be marked as processed using the
                 <span class="methodname">deleteMessage()</span> method. To do this, use
                 <span class="methodname">getMessages()</span> instead.
            </p>
        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.service.html">Zend_Service</a></li>
  <li><a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a></li>
  <li><a href="zend.service.akismet.html">Zend_Service_Akismet</a></li>
  <li><a href="zend.service.amazon.html">Zend_Service_Amazon</a></li>
  <li><a href="zend.service.amazon.ec2.html">Zend_Service_Amazon_Ec2</a></li>
  <li><a href="zend.service.amazon.ec2.instance.html">Zend_Service_Amazon_Ec2: Instances</a></li>
  <li><a href="zend.service.amazon.ec2.windows.instance.html">Zend_Service_Amazon_Ec2: Windows Instances</a></li>
  <li><a href="zend.service.amazon.ec2.reserved.instance.html">Zend_Service_Amazon_Ec2: Reserved Instances</a></li>
  <li><a href="zend.service.amazon.ec2.cloudwatch.html">Zend_Service_Amazon_Ec2: CloudWatch Monitoring</a></li>
  <li><a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a></li>
  <li><a href="zend.service.amazon.ec2.ebs.html">Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)</a></li>
  <li><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></li>
  <li><a href="zend.service.amazon.ec2.keypairs.html">Zend_Service_Amazon_Ec2: Keypairs</a></li>
  <li><a href="zend.service.amazon.ec2.zones.html">Zend_Service_Amazon_Ec2: Regions and Availability Zones</a></li>
  <li><a href="zend.service.amazon.ec2.securitygroups.html">Zend_Service_Amazon_Ec2: Security Groups</a></li>
  <li><a href="zend.service.amazon.s3.html">Zend_Service_Amazon_S3</a></li>
  <li><a href="zend.service.amazon.sqs.html">Zend_Service_Amazon_Sqs</a></li>
  <li><a href="zend.service.audioscrobbler.html">Zend_Service_Audioscrobbler</a></li>
  <li><a href="zend.service.delicious.html">Zend_Service_Delicious</a></li>
  <li><a href="zend.service.developergarden.html">Zend_Service_DeveloperGarden</a></li>
  <li><a href="zend.service.ebay.html">Zend_Service_Ebay</a></li>
  <li><a href="zend.service.ebay.finding.html">Zend_Service_Ebay_Finding</a></li>
  <li><a href="zend.service.flickr.html">Zend_Service_Flickr</a></li>
  <li><a href="zend.service.livedocx.html">Zend_Service_LiveDocx</a></li>
  <li><a href="zend.service.nirvanix.html">Zend_Service_Nirvanix</a></li>
  <li><a href="zend.service.recaptcha.html">Zend_Service_ReCaptcha</a></li>
  <li><a href="zend.service.short-url.html">Zend_Service_ShortUrl</a></li>
  <li><a href="zend.service.simpy.html">Zend_Service_Simpy</a></li>
  <li><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></li>
  <li><a href="zend.service.strikeiron.html">Zend_Service_StrikeIron</a></li>
  <li><a href="zend.service.strikeiron.bundled-services.html">Zend_Service_StrikeIron: Bundled Services</a></li>
  <li><a href="zend.service.strikeiron.advanced-uses.html">Zend_Service_StrikeIron: Advanced Uses</a></li>
  <li><a href="zend.service.technorati.html">Zend_Service_Technorati</a></li>
  <li><a href="zend.service.twitter.html">Zend_Service_Twitter</a></li>
  <li><a href="zend.service.windowsazure.html">Zend_Service_WindowsAzure</a></li>
  <li><a href="zend.service.windowsazure.storage.blob.html">Zend_Service_WindowsAzure_Storage_Blob</a></li>
  <li><a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a></li>
  <li class="active"><a href="zend.service.windowsazure.storage.queue.html">Zend_Service_WindowsAzure_Storage_Queue</a></li>
  <li><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></li>
  <li><a href="zend.service.yahoo.html">Zend_Service_Yahoo</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>